FROM debian:12-slim

# 构建时间参数与版本信息
ARG BUILD_TIME
ENV VERSION=v0.7-beta-${BUILD_TIME}

# 设置 PATH
ENV PATH="/usr/local/nginx/sbin:/usr/local/redis/bin:/usr/local/python/bin:${PATH}"

# 拷贝配置与启动脚本
COPY resource/sources.list /etc/apt/sources.list
# COPY resource/python3 /usr/local/python3
COPY resource/nginx /usr/local/nginx
COPY resource/redis /usr/local/redis
COPY resource/start.sh /root/.init/start.sh

# 确保启动脚本可执行
RUN chmod +x /root/.init/start.sh
# RUN chmod +x /usr/local/python3/bin/*
RUN chmod +x /usr/local/nginx/sbin/*
RUN chmod +x /usr/local/redis/bin/*

# 安装最基础的系统与调试工具
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    python3.11 \
    build-essential \
    gcc \
    libffi-dev \
    python3-dev \
    ca-certificates \
    file \
    libssl3 \
    libbz2-1.0 \
    liblzma5 \
    libncurses6 \
    libreadline8 \
    libsqlite3-0 \
    libffi8 \
    libgdbm6 \
    zlib1g \
    libuuid1 \
    procps \
    curl \
    wget \
    nano \
    less \
    net-tools \
    iproute2 \
    lsof \
    dnsutils \
    tcpdump \
    libpcre3 \
    libcap2 \
    openssl \
    unzip \
    python3-pip \
    python3.11-venv \
    pkg-config \
    apt-transport-https \
    libpcre3-dev \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | tee /etc/apt/keyrings/adoptium.asc
RUN echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list
RUN apt-get update
RUN apt-get install -y temurin-8-jdk && apt-get clean && rm -rf /var/lib/apt/lists/*


# 添加环境变量
ENV PATH="/usr/local/nginx/sbin:/usr/local/redis/bin:/usr/lib/jvm/temurin-8-jdk-amd64/bin:${PATH}"

# 容器启动命令
CMD ["/root/.init/start.sh"]
